

************* This program generates Figure 2 and Figure 5 in the paper *************


clear all
set more off

cd "$localdir\Data"
global output "$localdir\Output"


********* Load data *********

use data_survey2018, clear



********* Graphs *********


*** Network interaction: Family, school, any coworker by general discussion last year and economics/politics discussion last year (2x3 figure)

tabstat family_general_year, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'-4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist family_general_year, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Family Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(a, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical))



tabstat workall_general_year, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'+4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist workall_general_year, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Coworker Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(b, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical))



tabstat school_general_year, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'-4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist school_general_year, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Education Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(c, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical) orient(vertical))



tabstat family_econ_pol, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'-4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist family_econ_pol, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Family Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(d, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical))



tabstat workall_econ_pol, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'-4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist workall_econ_pol, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Coworker Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(e, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical))



tabstat school_econ_pol, s(mean median) save
matrix stats=r(StatTotal)
local mean=stats[1,1]
global mean = "`mean'"
di $mean
local meanline=`mean'+4.5
global meanline = "`meanline'"
di $meanline

local median=stats[2,1]
global median = "`median'"
di $median
local medianline=`median'-4.5
global medianline = "`medianline'"
di $medianline
matrix drop stats

graph set window fontface "Helvetica"
hist school_econ_pol, scheme(s1color) color(cranberry) width(5) percent discrete gap(50) title("", ///
size(medium) margin(medium)) ylabel(0 (20) 80, labsize(medium)) xlabel(0 (20) 100, labsize(medium)) xtitle("% Education Ties Conversed with", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*3)) name(f, replace) ///
xline($mean, lcolor(black) lwidth(*0.5)) text(73 $meanline "Mean", size(medium) orient(vertical)) ///
xline($median, lcolor(black) lwidth(*0.5)) text(72 $medianline "Median", size(medium) orient(vertical))

gr combine a b c d e f, ///
title("General Conversations within the Last Year", color(black) margin(b=-2) size(medium)) ///
subtitle("Conversations about Economics or Politics within the Last Year (Lower Bound)", color(black) position(0) ring(0) margin(t=5 b=5) size(medium)) ///
graphregion(color(white)) rows(2) imargin(t=5 b=8) plotregion(margin(t=0.05))
gr export "$output/fg2.pdf", replace
gr export "$output/fg2.eps", replace



*** Information transmission

graph set window fontface "Helvetica"
hist talk_about_unemp_event, scheme(s1color) color(cranberry) width(1) percent discrete gap(70) title("Talk to Others about the Event", size(medium)) ///
ylabel(0 (20) 80, labsize(medium)) xlabel(1 (1) 5, valuelabel labsize(*0.9)) xtitle("", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*4)) name(a, replace)

hist talk_about_unemp_risk, scheme(s1color) color(cranberry) width(1) percent discrete gap(70) title("Talk to Others about Unemployment Risk", size(medium)) ///
ylabel(0 (20) 80, labsize(medium)) xlabel(1 (1) 5, valuelabel labsize(*0.9)) xtitle("", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*4)) name(b, replace)

hist talk_about_ui, scheme(s1color) color(cranberry) width(1) percent discrete gap(70) title("Talk to Others about UI", size(medium)) ///
ylabel(0 (20) 80, labsize(medium)) xlabel(1 (1) 5, valuelabel labsize(*0.9)) xtitle("", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*4)) name(c, replace)

hist talk_about_left, scheme(s1color) color(cranberry) width(1) percent discrete gap(70) title("Talk to Others about Left Politicians", size(medium)) ///
ylabel(0 (20) 80, labsize(medium)) xlabel(1 (1) 5, valuelabel labsize(*0.9)) xtitle("", size(medium)) ytitle("% of Respondents", size(medium)) ///
graphregion(color(white)) yscale(titlegap(*2)) xscale(titlegap(*4)) name(d, replace)

gr combine a b c d, title("", color(black)) graphregion(color(white)) 
gr export "$output/fg5.pdf", replace
gr export "$output/fg5.eps", replace

